home *** CD-ROM | disk | FTP | other *** search
/ Photography Workshop / PhotoWorkShop.iso / pc / Content / Find / Find.cst / 00003_Parser Scripts.ls < prev    next >
Encoding:
Text File  |  2002-04-15  |  3.6 KB  |  110 lines

  1. global lineNum
  2. global indexText
  3. global masterList
  4.  
  5. on SpinToNextWorkshop
  6.   repeat while char 1 of line lineNum of indexText <> "ΓÇó" and lineNum < the number of lines in indexText
  7.     set lineNum to lineNum + 1
  8.   end repeat
  9. end
  10.  
  11. on ParseIndex
  12.   set the itemdelimiter to ";"
  13.   
  14.   OpenXtras
  15.   
  16.   set indexText to ReadTextFile( the MoviePath &"Index Text" )
  17.   
  18.   set MasterList to [:]
  19.   
  20.   set linenum to 1
  21.   repeat while true
  22.     SpinToNextWorkshop
  23.     
  24.     if lineNum >= the number of lines in indexText then exit repeat
  25.     
  26.     set theWorkshopID to char 2 to 4 of line lineNum of indexText
  27.     
  28.     set lineNum to lineNum + 1
  29.     set theTeachMeID to line lineNum of indexText
  30.     
  31.     set theWorkshopID to UpShift( theWorkshopID )
  32.     set theTeachMeID to UpShift( theTeachMeID )
  33.     
  34.     put "Workshop" && theWorkshopID && "TeachMe ID" && theTeachMeID && the freebytes
  35.     set lineNum to lineNum + 1
  36.     set thisLine to line lineNum of indexText
  37.     repeat with i = 1 to the number of items in thisLine
  38.       set thisKeyPhrase to item i of thisLine
  39.       repeat while char 1 of thisKeyPhrase = " "
  40.         delete char 1 of thisKeyPhrase
  41.       end repeat
  42.       --put thisKeyPhrase
  43.       
  44.       if thisKeyPhrase contains QUOTE then
  45.         put "Quote in keyphrase" && thisKeyPhrase
  46.       end if
  47.       if thisKeyPhrase contains TAB then
  48.         put "Tab in keyphrase" && thisKeyPhrase
  49.       end if
  50.       if thisKeyPhrase contains RETURN then
  51.         put "Return in keyphrase" && thisKeyPhrase
  52.       end if
  53.       
  54.       --set thisKeyPhrase to UpShift( thisKeyPhrase )
  55.       
  56.       set foundKeyValue to getaprop( masterlist, thisKeyPhrase )
  57.       
  58.       if theTeachMeID = "none" then
  59.         set TeachMeList to [ ]
  60.       else
  61.         set TeachMeList to [ theTeachMeID ]
  62.       end if
  63.       set WorkshopList to [:]
  64.       
  65.       if voidp(foundKeyValue) then
  66.         -- keyphrase is not in list        
  67.         AddProp( WorkshopList, theWorkshopID, TeachMeList )
  68.         addprop( masterlist, thisKeyPhrase, WorkshopList )
  69.       else
  70.         -- key phrase is in list
  71.         --put thisKeyPhrase && "in the list" && foundKeyValue
  72.         set foundTeachMeList to getaprop( foundKeyValue, theWorkshopID )
  73.         if voidp(foundTeachMeList) then
  74.           --put "adding workshop to keyphrase" && theWorkshopID && TeachMeList
  75.           AddProp( foundKeyValue, theWorkshopID, TeachMeList )
  76.         else
  77.           add( foundTeachMeList, theTeachMeID )
  78.           --put "need to add teachme ID to workshop list" && theWorkshopID && theTeachMeID
  79.         end if
  80.       end if
  81.     end repeat
  82.   end repeat
  83.   sort ( MasterList )
  84.   put listp( value( string( masterlist ) ) )
  85.   set theLength to the number of chars of string(MasterList)
  86.   set the text of cast "Master1" of castlib "Find" to char 1 to 30000 of string(MasterList)
  87.   set the text of cast "Master2" of castlib "Find" to char 30001 to theLength of string(MasterList)
  88.   
  89.   
  90.   set keywords to ""
  91.   repeat with i = 1 to count( MasterList )
  92.     set thisKeyPhrase to getpropat( masterlist, i )
  93.     put thisKeyPhrase & RETURN after keywords
  94.   end repeat
  95.   set the text of cast "Topics" of castlib "Shared" to keywords
  96. end
  97.  
  98. on FixWorkshopLongNames
  99.   OpenXtras
  100.   set longnamelist to [:]
  101.   set oldLongNameList to value(the text of cast "longnames" of castlib "find")
  102.   repeat with i = 1 to count( oldLongNameList )
  103.     set thisPageShortName to getpropat(oldLongNameList, i)
  104.     set thisPageShortName to UpShift( thisPageShortName ) 
  105.     addprop( longnamelist, thisPageShortName, getat( oldLongNameList, i ) )
  106.   end repeat
  107.   put longnamelist
  108.   set the text of cast "longnames" of castlib "find" to string( longNameList )
  109. end
  110.